package com.rustic.server.dto;

import cn.hutool.core.bean.BeanUtil;
import cn.xy.commons.validator.EnumValidator;
import com.rustic.server.enums.CategoryType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.rustic.server.po.Category;
import com.rustic.server.dto.base.CategoryBaseDTO;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;;

/**
 * 表[category]对应AddDTO类
 *
 * @author auto
 */

@Data
@EqualsAndHashCode(callSuper = true)
public class CategoryAddDTO extends CategoryBaseDTO {
    /**
     * 分类名称
     */
    @NotEmpty(message = "分类名称不能为空")
    @Length(min = 0, max = 100, message = "分类名称长度为0-100个字符")
    @ApiModelProperty(value = "分类名称", dataType = "String")
    private String name;

    /**
     * 类型(1活动类型 2景点等级 3景点类型 4美食分类 5攻略分类)
     */
    @EnumValidator(clazz = CategoryType.class, message = "请输入正确的类型")
    @ApiModelProperty(value = "类型(1活动类型 2景点等级 3景点类型 4美食分类 5攻略分类)", dataType = "int")
    private int type;

    /**
     * 排序
     */
    @Min(value = 0, message = "排序权重最小为0")
    @Max(value = 9999, message = "排序权重最大为9999")
    @ApiModelProperty(value = "排序", dataType = "int")
    private int sort;

    /**
     * 备注
     */
    @Length(min = 0, max = 100, message = "备注长度为0-100个字符")
    @ApiModelProperty(value = "备注", dataType = "String")
    private String remark;


    public Category toCategory() {
        Category category = new Category();
        BeanUtil.copyProperties(this, category);
        return category;
    }
}
